Skip to content

fix(server): reconcile Codex usage counters - #11322

Open
shivamhwp wants to merge 2 commits into
fix/server-usage-scan-coveragefrom
fix/server-codex-usage-reconciliation
Open

fix(server): reconcile Codex usage counters#11322
shivamhwp wants to merge 2 commits into
fix/server-usage-scan-coveragefrom
fix/server-codex-usage-reconciliation

Conversation

@shivamhwp

@shivamhwp shivamhwp commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

Codex can emit changed request counters without advancing cumulative usage. We counted those events again, turning 120 processed tokens into 145 in the reported case. Identical consecutive requests could also disappear even when cumulative usage advanced.

Validate each request against cumulative counters, skip stale events, and report inconsistent sequences as partial coverage. Preserve legacy events without cumulative data and Codex's non-billing context-window estimates. Carry the counters and diagnostics through incremental reads and restart, and invalidate the old scan cache.

Fixes #5800. Stacked on #11321 for scan coverage reporting. Both branches include current main. Internal refinement remains pending after the final Fable retry failed. No merge requested.

Validation: 85 focused tests pass; six new regressions fail against the parent implementation and three mixed-format regressions fail against the first PR commit. Server typecheck and scoped lint pass. The native Node reproduction now returns 120 tokens; a read-only local transcript replay covers 24 usage events with no malformed-counter warning. This is not a survey of every Codex version. Existing source coverage fields carry the result to web, desktop, mobile and remote clients.

Model: GPT-6. Harness: Codex.

Rebased on main 20363c32c9bfdbf49c2716ef11d1f18483fcc01b. Scoped validation rerun after rebasing; existing native and human review limits remain.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Sep 11, 2026
Comment thread apps/server/src/usage/usageTranscripts.ts Outdated
@macroscopeapp

macroscopeapp Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This PR changes the production Codex usage parser, incremental scan state, cache format, and derived usage/pricing diagnostics. Because it changes existing metering behavior and persists new reconciliation state, the scope and impact warrant human review.

You can add or adjust custom eligibility rules. Learn more.

@github-actions

github-actions Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

ℹ️ No successful main baseline artifact is available yet. This run establishes the initial measurement.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 13.6 KiB 15.1 KiB
Codex Thread snapshot wire 7.0 KiB 7.3 KiB
Codex Live turn WebSocket wire 6.5 KiB 7.8 KiB
Codex Live turn WebSocket decoded 57.0 KiB 66.4 KiB
Codex Live turn messages 8 21
Claude Total thread wire 13.5 KiB 15.1 KiB
Claude Thread snapshot wire 7.1 KiB 7.3 KiB
Claude Live turn WebSocket wire 6.5 KiB 7.8 KiB
Claude Live turn WebSocket decoded 57.8 KiB 66.4 KiB
Claude Live turn messages 8 21

Baseline: unavailable · PR result: 811e298 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 113.9 KiB
  • Claude decoded thread snapshot: 114.6 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@shivamhwp
shivamhwp force-pushed the fix/server-usage-scan-coverage branch from 89f0222 to 47e8390 Compare September 13, 2026 15:39
@shivamhwp
shivamhwp force-pushed the fix/server-codex-usage-reconciliation branch from 23540d4 to 811e298 Compare September 13, 2026 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant